# -*- coding: utf-8 -*-
import unittest
from selenium import webdriver
import time
import xlrd
from Page.loginPage import loginPage
from publicModule.login import login
from Page.noscanningPage import noscanningPage
from publicModule.noscanning import noscanning
from publicModule.manreview import manreview
from publicModule.policyholder import policyholder
from Page.policyholderPage import policyholderPage
from Page.manreviewPage import manreviewPage
class Test_ManReview(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        print('开始测试')
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        self.driver.get("http://10.22.26.34:8080/fwd/indexlis.jsp")
        time.sleep(2)
        self.loginPage = loginPage(self.driver)
        self.login = login(self.driver)
        self.noscanningPage = noscanningPage(self.driver)
        self.noscanning = noscanning(self.driver)
        self.manreview=manreview(self.driver)
        self.manreviewPage=manreviewPage(self.driver)
        self.policyholder = policyholder(self.driver)
        self.policyholderPage = policyholderPage(self.driver)

    @classmethod
    def tearDownClass(self):
        print('结束测试')
        self.driver.quit()
    def test01(self):
        print('test01')
        filename = '..//TestData//loginData.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            username = row_content[3]
            password = row_content[4]
            orgcode = int(row_content[5])
            login.login(self, username, password, orgcode)
    def test02(self):
        print('人工核保')
        noscanning.noscanning(self)
        time.sleep(1)
        noscanning.noscanning1(self)
        time.sleep(1)
        manreview.manreviewpage(self)
        time.sleep(1)
    def test03(self):
        print('从公共池申请到个人池')
        filename = r'..\TestData\outputdata.xls'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(1, rows):
            row_content = table.row_values(i)
            GrpPropNo = row_content[0]
            manreview.query_manreview(self,GrpPropNo)
        manreview.self_goto_public(self)
    def test04(self):

        print('新单复核、人工核保')
        filename = '..//TestData//underwriting.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            UWConclusion = row_content[0]
            UWOption = row_content[1]
            manreview.UnderWritingProcess(self,UWConclusion,UWOption)
        # UWConclu = row_content[2]
        # UWIdea = row_content[3]
        manreview.InsuredListConfirm(self)


if __name__ =='__main__':
    # unittest.main()
    suite = unittest.TestLoader.loadTestsFromTestCase(Test_ManReview)
    unittest.TextTestRunner().run(suite)



